package com.spark.incoicings.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spark.incoicings.dao.PaymentMapper;
import com.spark.incoicings.service.PaymentService;
import com.spark.incoicings.vo.PaymentVO;
import com.spark.invoicings.entity.Payment;
import com.spark.invoicings.utils.Result;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class PaymentServiceImpl extends ServiceImpl<PaymentMapper, Payment> implements PaymentService {

    @Resource
    private PaymentMapper paymentMapper;
    @Override
    public Result selectPaymentCount() {
        List<PaymentVO> payments = paymentMapper.selectPaymentCount();
        payments.forEach(s->{
            String year = s.getMonth().substring(0,4);
            String month = s.getMonth().substring(4);
            String yearMonth = year+"年"+month+"月";
            s.setMonth(yearMonth);
        });
        return Result.success(200,"success",payments);
    }
}
